---
title: "Map Dashboard"
output:
flexdashboard::flex_dashboard:
orientation: rows
vertical_layout: fill
source_code: embed
runtime: shiny
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(eval = T, echo = F, message = F, cache=F)
library(flexdashboard)
library(tidyverse)
library(plotly)
library(readxl)
library(here)
library(knitr)
library(maps)
library(usmap)
library(shiny)
library(lubridate)
```
```{r}
#confirmed
covid.data.case <- read.csv(here::here("us_covid_confirmed_07062021.csv"))
covid.data.7 <- subset(covid.data.case, month=="7")
covid.data.705 <- subset(covid.data.7, day=="5")
covid.data.case.70521 <- subset(covid.data.705, year=="21" )
#deaths
covid.data.death <- read.csv(here::here("us_covid_deaths_07062021.csv"))
covid.data.2.7 <- subset(covid.data.death, month=="7")
covid.data.2.705 <- subset(covid.data.2.7, day=="5")
covid.data.death.70521 <- subset(covid.data.2.705, year=="21" )
```
Column {data-width=650}
-----------------------------------------------------------------------
### U.S. Confirmed Cases
```{r}
confirmed <- plot_usmap(regions="states",data = covid.data.case.70521,
values = "confirmed",
size = .05,
theme = theme_minimal()) +
theme(axis.title = element_blank(),
axis.ticks = element_blank(),
axis.text = element_blank()) +
labs(fill = "confirmed") +
viridis::scale_fill_viridis()
ggplotly(confirmed)
```
### U.S. Deaths
```{r}
deaths <- plot_usmap(data = covid.data.death.70521,
values = "deaths",
size = .05,
theme = theme_minimal()) +
theme(axis.title = element_blank(),
axis.ticks = element_blank(),
axis.text = element_blank()) +
labs(fill = "deaths") +
viridis::scale_fill_viridis()
ggplotly(deaths)
```
### View Confirmed Cases and Deaths by State
```{r}
#states
states <-force(state.abb)
selectInput("statechoice", # name of the widget, will be used later as input
label = ("Select State to View"), # label the widget
choices = states, # use the states dataset as choices in dropdown
selected = "CT") # default selected is CA (something must be slected)
renderPlot({ # render the interactive plot - if you don't wrap in a render statement, the widgets won't change anything
plot_usmap(include = input$statechoice, # show only selected state using the input from widget
data = covid.data.case.70521,
values = "confirmed",
theme = theme_minimal()) +
theme(axis.title = element_blank(),
axis.ticks = element_blank(),
axis.text = element_blank()) +
labs(fill = "confirmed") +
viridis::scale_fill_viridis()
})
```
```{r}
renderPlot({ # render the interactive plot - if you don't wrap in a render statement, the widgets won't change anything
plot_usmap(include = input$statechoice, # show only selected state using the input from widget
data = covid.data.death.70521,
values = "deaths",
theme = theme_minimal()) +
theme(axis.title = element_blank(),
axis.ticks = element_blank(),
axis.text = element_blank()) +
labs(fill = "deaths") +
viridis::scale_fill_viridis()
})
```